#include "DXUT.h"
#include "RenderTargetChain.h"


CRenderTargetChain::CRenderTargetChain(void) : m_nNext( 0 ),
	m_bFirstRender( true )
{
 
}
 
CRenderTargetChain::~CRenderTargetChain(void)
{
	 
}

 

void CRenderTargetChain::OnD3D9DestroyDevice()
{
	 
}

HRESULT CRenderTargetChain::OnD3D9ResetDevice( IDirect3DDevice9* pd3dDevice )
{
	HRESULT hr;
	m_bFirstRender=( true );
	ZeroMemory( m_pRenderTargetTexture, sizeof( m_pRenderTargetTexture ) );
	 ZeroMemory( m_pRenderTargetSurface, sizeof( m_pRenderTargetSurface ) );
	const D3DSURFACE_DESC *pBackBufferSurfaceDesc=  DXUTGetD3D9BackBufferSurfaceDesc();

	for( int i=0; i<2; i++)
	{
		V_RETURN( pd3dDevice->CreateTexture( pBackBufferSurfaceDesc->Width,
			pBackBufferSurfaceDesc->Height,
			1,
			D3DUSAGE_RENDERTARGET,
			D3DFMT_A8R8G8B8,
			D3DPOOL_DEFAULT,
			& m_pRenderTargetTexture[i],
			NULL ) );

		m_pRenderTargetTexture[i]->GetSurfaceLevel(0,&m_pRenderTargetSurface[i]);
		
	}

	return hr;
}

void CRenderTargetChain::OnD3D9LostDevice()
{
	SAFE_RELEASE( m_pRenderTargetTexture[0] );
	SAFE_RELEASE( m_pRenderTargetTexture[1] );
	SAFE_RELEASE( m_pRenderTargetSurface[0] );
	SAFE_RELEASE( m_pRenderTargetSurface[1] );
}

HRESULT CRenderTargetChain::OnD3D9CreateDevice( IDirect3DDevice9* pd3dDevice )
{
	 
	return S_OK;
}

 

